<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    // 1.String基本使用
    var name = "coderwhy"
    var address = "广州市"
    var intro = "认真是一种可怕的力量!"

    // 2.别的引号的使用
    // 单引号
    var message1 = 'Hello World'
    // 双引号
    var message2 = "Hello World"
    // 反引号(ES6新增语法)
    // ${变量/表达式}
    var message3 = `Hello World, ${name}, ${2 + 3}`

    // 3.转义字符: 字符串本身中包含引号
    // 需求：coderwhy在输出的时候加个双引号
    var message4 = 'my name is "coderwhy"'
    console.log(message4) // => my name is "coderwhy"
    // 需求：字符串在输出的时候既有单引号，也有双引号和斜杠
    var message5 = 'my name \\ \'\' is "coderwhy"'
    console.log(message5) // => my name \ '' is "coderwhy"

    // 4.<字符串>本身有的方法和属性
    var message = "Hello World"
    console.log(message.length) // => 11

    // 字符串操作
    var nickname = "coderwhy"
    var info = "my name is "
    var infoStr = `my name is ${nickname}` // 推荐使用这种方式，babel可以解决es6的兼容问题
    var infoStr2 = info + nickname
    console.log(infoStr, infoStr2) // => my name is coderwhy my name is coderwhy

  </script>

</body>
</html>